<extend name="common:commonTemplate" />
<block name="main_content">
<div id="content">
	<style>
		.controls input[type=text]{width: 60%;}
	</style>
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="index.html"
				data-original-title="Go to Home"><i class="icon-home"></i> 首页</a> <a
				href="#">商品</a> <a class="current" href="#">sku信息列表</a>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i>
						</span>
						<h5>sku信息</h5>
					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate" id="basic_validate"
							name="basic_validate" action="#" method="post"
							class="form-horizontal">
							
							<div class="control-group">
                               <div class="controls">
                                   <input type="button" value="加载产品信息" class="btn btn-success" id="btn_product_search"/>
                               </div>
                            </div>
							<div class="control-group">
								<label class="control-label">产品编号:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.product_id}" readonly="readonly" id="product_id"
										name="product_id"><span style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">产品名称:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.product_name}"
										id="product_name" name="product_name" readonly="readonly"><span style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">客户物料号:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.material_no}"
										id="material_no" readonly="readonly" name="material_no"><span style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku编号:</label>
								<div class="controls">
									<input type="text" id="sku_id" value="{$sku_en.sku_id}"
										name="sku_id" readonly="readonly" /><span style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku编码:</label>
								<div class="controls">
									<input type="text" id="sku_sn" value="{$sku_en.sku_sn}"
										name="sku_sn" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku名称:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sku_name}" id="sku_name"
										name="sku_name"><span style="color:red;">*</span>
								</div>
							</div>

							<div class="control-group">
								<label class="control-label">促销信息</label>
								<div class="controls">
									<input type="text" id="promotion_text" name="promotion_text" value="{$sku_en.promotion_text}">
								</div>
							</div>

							<div class="control-group">
								<label class="control-label">商品编号:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.style_id}" id="style_id"
										name="style_id"><span style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">商品编码:</label>
								<div class="controls">
									<input type="text" id="style_sn" value="{$sku_en.style_sn}" name="style_sn"><span
										style="color:red;">*</span>

								</div>
							</div>
							<div class="control-group">
								<label class="control-label">商品名称:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.style_name}" id="style_name"
										name="style_name"><span style="color:red;">*</span>
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label">sku渠道:</label>
								<div class="controls">
									<select id="sku_channel" name="sku_channel" style="width: 62%">
										
								 <if condition="$sku_en.sku_channel eq '1'">
								
										<option value="1" selected="selected">淘宝</option>
										
								   <else/>
								 
										<option value="1">淘宝</option>
										
								</if>
								
								
								
								 <if condition="$sku_en.sku_channel eq '2'">
								
										
										<option value="2" selected="selected">京东</option>
										
								   <else/>
								   
										<option value="2">京东</option>
										
								</if>
								
								
								
								 <if condition="$sku_en.sku_channel eq '3'">
								
										<option value="3" selected="selected">官网</option>
										
								   <else/>
								   
										<option value="3">官网</option>
										
								</if>
								
								
								 <if condition="$sku_en.sku_channel eq '5'">
								
										<option value="5" selected="selected">英雄会O2O</option>
										
								   <else/>
								  
										<option value="5">英雄会O2O</option>
										
								</if>
								
								
								 <if condition="$sku_en.sku_channel eq '6'">
								
										<option value="6" selected="selected">村淘</option>
										
								   <else/>
								   
										<option value="6">村淘</option>
										
								</if>
								
								 <if condition="$sku_en.sku_channel eq '8'">
								
										<option value="8" selected="selected">大客户</option>
										
								   <else/>
								  
										<option value="8">大客户</option>
									
								</if>
								
								
								<if condition="$sku_en.sku_channel eq '10'">
								
										<option value="10" selected="selected">VR渠道</option>
										
								   <else/>
								  
										  <option value="10">VR渠道</option>
									
								</if>
								
								<if condition="$sku_en.sku_channel eq '11'">
								
										<option value="11" selected="selected">四川电信</option>
										
								   <else/>
								  
									<option value="11">四川电信</option>
									
								</if>
								<if condition="$sku_en.sku_channel eq '13'">

									<option value="13" selected="selected">等级品</option>

									<else/>

									<option value="13">等级品</option>

								</if>

									</select><span style="color:red;">*</span>
								</div>
							</div>
							
                      <div class="control-group">
                                <label class="control-label">sku描述性URL:</label>
                                <div class="controls">
                                    <input type="text" id="desc_url" name="desc_url" value="{$sku_en.desc_url}">
                                </div>
                            </div>


							<!-- <div class="control-group">
								<label class="control-label">sku维度1编号:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sku_dimension_id1}"
										id="sku_dimension_id1" name="sku_dimension_id1">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku维度1名称:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sku_dimension_name1}"
										id="sku_dimension_name1" name="sku_dimension_name1">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku维度1值:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sku_dimension_value1}"
										id="sku_dimension_value1" name="sku_dimension_value1">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku维度2编号:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sku_dimension_id2}"
										id="sku_dimension_id2" name="sku_dimension_id2">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku维度2名称:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sku_dimension_name2}"
										id="sku_dimension_name2" name="sku_dimension_name2">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">sku维度2值:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sku_dimension_value2}"
										id="sku_dimension_value2" name="sku_dimension_value2">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">是否按城市价格销售:</label>
								<div class="controls">
									<select id="is_city_price" name="is_city_price" style="width: 220px;">
										<option value="0">非</option>
										<option value="1">是</option>
									</select>
								</div>
							</div> -->
							<div class="control-group">
								<label class="control-label">市场价:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.market_price}"
										id="market_price" name="market_price">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">单价:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.sale_price}" id="sale_price"
										name="sale_price"><span
                                            style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">退款价格:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.return_price}" id="return_price"
										   name="return_price"><span
										style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">优先级:</label>
								<div class="controls">
									<input type="text" id="priority" name="priority" value="{$sku_en.priority}" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
										   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}">
								</div>
							</div>

							<div class="control-group">
								<label class="control-label">经销商渠道最低限价:</label>
								<div class="controls">
									<input type="text" id="dealer_min_limit_price"value="{$sku_en.dealer_min_limit_price}" name="dealer_min_limit_price">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">个人提成金额:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.person_commission_amount}"
										id="person_commission_amount" name="person_commission_amount">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">经销商提成金额:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.dealer_commission_amount}"
										id="dealer_commission_amount" name="dealer_commission_amount">
								</div>
							</div>

							<div class="control-group">
								<label class="control-label">是否支持返点</label>
								<div class="controls">
									<select type="text" id="is_rebate" name="is_rebate"  style="width: 62%">
										<if condition="$sku_en.is_rebate eq 0 ">
											<option value="0" selected>否</option>
											<option value="1" >是</option>
											<else />
											<option value="0">否</option>
											<option value="1" selected>是</option>
										</if>

									</select>
								</div>
							</div>

							<div class="control-group">
								<label class="control-label">是否是礼品</label>
								<div class="controls">
									<select type="text" id="is_gift" name="is_gift"  style="width: 62%">
										<if condition="$sku_en.is_gift eq 0 ">
											<option value="0" selected>否</option>
											<option value="1">是</option>
											<else />
											<option value="0">否</option>
											<option value="1" selected>是</option>
										</if>

									</select>
								</div>
							</div>

							<div class="control-group">
								<label class="control-label">图片:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.image}" id="image"
										name="image">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">图片集合:</label>
								<div class="controls">
									<input type="text" value="{$sku_en.image_list}" id="image_list"
										name="image_list">
								</div>
							</div>

							<div class="control-group">
								<label class="control-label">状态:</label>
								<div class="controls">
									<select id="status" name="status" style="width: 62%">
										<if condition="$sku_en.status eq '0'">
									<option value="0" selected="selected">无效</option>
									<else/>
									<option value="0">无效</option>
									</if>
									<if condition="$sku_en.status eq '1'">
									<option value="1" selected="selected">有效</option>
									<else/>
									<option value="1">有效</option>
									</if>
									</select>
								</div>
							</div>
							
                            <div class="control-group">
                            	<label class="control-label">会员服务<span class="required-tips">*</span></label>
                                <div class="controls">
                                    <select id="referent_id" name="referent_id"  style="width: 62%" >
                                    	<option value="0">不选择</option>
                                    	<foreach name="vip_bag_lst" item="itm" key="key">
											<option value="{$itm.id}">{$itm.invoice_name}</option>
										</foreach >
                                	</select>
                            	</div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">开票名称<span class="required-tips">*</span></label>
                                <div class="controls">
                                    <input type="text" id="invoice_title" name="invoice_title" value="{$product_split.invoice_title}" maxlength="30">
                                </div>
                            </div>
							<div class="control-group">
								<a id="btn_updateSku" class="btn btn-success">修改商品</a>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</block>


<block name="js_content"> 
<script src="/Public/js/layer/layer.js" type="text/javascript"></script>
<script>
	SkuPageInfo = {
         'BindEvent': function () {
             $('#btn_product_search').bind('click', function () {
                 SkuPageInfo.SearchProduct();
             });
             $('#btn_updateSku').bind('click', function () {
                 SkuPageInfo.UpdateSku();
             });
         },
         'UpdateSku' : function(){
			var sku_channel_name = encodeURIComponent($('#sku_channel').find("option:selected").text());
			var condition = $('#basic_validate').serialize();
			condition += "&sku_channel_name="+sku_channel_name;
			$.ajax({
                type: 'post',
                url: '/AjaxService/center/sku/updateSku',
                data: condition,
                dataType: 'json',
                async: false,
                success: function (data) {
                    if (data.IsSuccess == 0) {
                        alert(data.ErrorMsg);
                        return;
                    } else {
                        alert('操作成功');
                    }
                },
                error: function (e, err_name, err_text) {

                }
            });
         },
         'SearchProduct': function () {
             var product_id = $('#product_id').val();
             var product_name = encodeURIComponent($('#product_name').val());
             var material_no = $('#material_no').val();
             layer.open({
                 type: 2,
                 title: '产品搜索',
                 skin: 'whaley-layui-search',
                 fix: true,
                 shadeClose: true,
                 maxmin: true,
                 area: ['1000px', '600px'],
                 content: '/sku/productinfosearch?product_id=' + product_id + '&product_name=' + product_name + '&material_no=' + material_no,
                 end: function () {
                 	
                 }
             });
         },
         'BuildPage': function (data) {
         	//填充数据
         	var product = data.Result.product;
             $('#product_id').val(product.product_id);
             $('#product_name').val(product.product_name);
             $('#material_no').val(product.material_no);
             $('#sku_name').val(product.product_name);
             $('#style_name').val(product.product_name);
             $('#image').val(product.image);
             $('#image_list').val(product.image_list);
             $('#invoice_title').val(product.invoice_title);
            /*  
             $('#style_id').val(SkuService.GetStyleID()['Result']);
             $('#style_sn').val($('#style_id').val());
             //style_id
             var sku_val = SkuService.GetSkuID()['Result'];
             $('#sku_id').val(sku_val);
             $('#sku_sn').val(sku_val); */
         },
	};
	function setChannelName(obj){
		var channel_name= $(obj).find("option:selected").text();
		$('#sku_channel_name').val(channel_name);
	}
	$(document).ready(function() {
		SkuPageInfo.BindEvent();
        $('#referent_id').select2('val',{$product_split.referent_id});
	});
</script> </block>